package com.zh.remote.fallback;

import com.zh.remote.api.BigdataApi;
import com.zh.remote.pojo.param.DriverPointResult;
import com.zh.result.JSONResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
@Slf4j
public class BigdataApiFallback implements FallbackFactory<BigdataApi> {
    @Override
    public BigdataApi create(Throwable cause) {
        return new BigdataApi(){
            @Override
            public JSONResult<List<DriverPointResult>> selectDriverPointByOrderNo(String customerId) {
                // 打印异常日志
                log.error("BigdataApi 服务调用失败{}", cause.getMessage());
                return JSONResult.error("远程调用失败" + cause.getMessage());
            }
        };
    }
}
